package at.sysarch.bean;

import java.awt.Rectangle;

import javax.media.jai.PlanarImage;

import at.pimpmypipe.interfaces.Readable;
import at.sysarch.domain.TransferImage;
import at.sysarch.filter.ROIFilter;
import at.sysarch.utils.LinkEvent;
import at.sysarch.utils.LinkListener;

public class ROI extends AbstractBean<ROIFilter> implements LinkListener {

	private static final long serialVersionUID = 1L;
	public static PlanarImage IMAGE;

	public ROI() {
		_filter = new ROIFilter(this);
	}

	@Override
	public void displayImage(TransferImage image) {
		super.displayImage(image);
		
		IMAGE = image.getSourceImage();
	}

	@Override
	public void linkBean(LinkEvent event) {
		_filter.setInput(event.getInput());
		event.getInput().setOutput(_filter);
		_filter.run();
	}

	@Override
	public void addLinkListener(LinkListener listener) {
		listener.linkBean(new LinkEvent((Readable<TransferImage>)_filter));
	}

	@Override
	public void removeLinkListener(LinkListener listener) {	
		
	}
	
	public Rectangle getRectangle() {
		return _filter.getRectangle();
	}

	public void setRectangle(Rectangle rectangle) {
		_filter.setRectangle(rectangle);
	}
}